<template>
  <hips-view>
    <hips-nav-bar
      slot="header"
      title="Stepper 步进器"
      :back-button="{
        showLeftArrow: true,
      }"
      @nav-bar-back-click="$router.back()"
    />

    <hips-tabs
      slot="sub-header"
      v-model="active"
    >
      <hips-tab title="标准用法" />
      <hips-tab title="Dsx用法" />
    </hips-tabs>

    <div v-show="!active">
      <demo-block title="基础用法">
        <hips-stepper
          v-model="data0"
          step="0.1"
          max="200"
        />
      </demo-block>

      <demo-block title="整数增减">
        <hips-stepper
          v-model="data1"
          integer
          step="2"
          min="0"
        />
      </demo-block>

      <demo-block title="禁用">
        <hips-stepper
          v-model="data2"
          step="2"
          min="0"
          disabled
        />
      </demo-block>

      <demo-block title="尺寸">
        <hips-stepper
          v-model="data3"
          step="2"
          min="0"
          size="large"
        />
      </demo-block>

      <demo-block title="高级用法">
        <hips-group>
          <hips-cell title="选择">
            <hips-stepper
              slot="right-icon"
              v-model="data4"
              step="2"
              min="0"
            />
          </hips-cell>
        </hips-group>
      </demo-block>
    </div>
    <div v-show="active">
      <demo-block title="基础用法">
        <hips-stepper :d-field="dsx.records.at(0).getField('data0')" />
      </demo-block>

      <demo-block title="整数增减">
        <hips-stepper :d-field="dsx.records.at(0).getField('data1')" />
      </demo-block>

      <demo-block title="禁用">
        <hips-stepper :d-field="dsx.records.at(0).getField('data2')" />
      </demo-block>

      <demo-block title="尺寸">
        <hips-stepper :d-field="dsx.records.at(0).getField('data3')" />
      </demo-block>

      <demo-block title="高级用法">
        <hips-group>
          <hips-cell title="选择">
            <hips-stepper
              slot="right-icon"
              :d-field="dsx.records.at(0).getField('data4')"
            />
          </hips-cell>
        </hips-group>
      </demo-block>
    </div>
  </hips-view>
</template>

<script>
import BasicView from '@/mixin/basic-view';
import { Group, Cell, Stepper, Tabs, Tab } from '@hips/vue-ui';
import Dsx from '@hips/plugin-dataset-vuex';

export default {
  components: {
    [Group.name]: Group,
    [Cell.name]: Cell,
    [Stepper.name]: Stepper,
    [Tabs.name]: Tabs,
    [Tab.name]: Tab,
  },
  mixins: [ BasicView ],
  data() {
    return {
      active: 0,
      data0: 21.2,
      data1: 3.2,
      data2: 8.2,
      data3: 8.2,
      data4: 8.2,
      dsx: new Dsx({
        moduleName: 'dsx-stepper',
        autoCreate: true,
        fields: [
          {
            name: 'data0',
            defaultValue: 21.2,
            step: 0.1,
            max: 200,
          },
          {
            name: 'data1',
            defaultValue: 3.2,
            integer: true,
            step: 2,
            min: 0,
          },
          {
            name: 'data2',
            defaultValue: 8.2,
            step: 2,
            min: 0,
            disabled: true,
          },
          {
            name: 'data3',
            defaultValue: 8.2,
            step: 2,
            min: 0,
            size: 'large',
          },
          {
            name: 'data4',
            defaultValue: 8.2,
            step: 2,
            min: 0,
          },
        ],
      }),
    };
  },
};
</script>

<style lang="stylus" scoped>
>>> .demo-block {
    .wrapper {
        padding 10px
    }
}
</style>
